package com.ruoyi.equipmentBook.service.impl;

import java.util.List;

import com.ruoyi.equipmentBook.Vo.EquimentBookVo;
import com.ruoyi.equipmentBook.Vo.EquipmentBookListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.equipmentBook.mapper.EquipmentBookMapper;
import com.ruoyi.equipmentBook.domain.EquipmentBook;
import com.ruoyi.equipmentBook.service.IEquipmentBookService;

/**
 * 设备基础台账Service业务层处理
 *
 * @author pengjie
 * @date 2023-12-20
 */
@Service
public class EquipmentBookServiceImpl implements IEquipmentBookService
{
    @Autowired
    private EquipmentBookMapper equipmentBookMapper;

    /**
     * 查询设备基础台账
     *
     * @param equipmentId 设备基础台账主键
     * @return 设备基础台账
     */
    @Override
    public EquipmentBook selectEquipmentBookByEquipmentId(String equipmentId)
    {
        return equipmentBookMapper.selectEquipmentBookByEquipmentId(equipmentId);
    }

    /**
     * 查询设备基础台账列表
     *
     * @param equipmentBook 设备基础台账
     * @return 设备基础台账
     */
    @Override
    public List<EquipmentBook> selectEquipmentBookList(EquipmentBook equipmentBook)
    {
        return equipmentBookMapper.selectEquipmentBookList(equipmentBook);
    }

    /**
     * 新增设备基础台账
     *
     * @param equipmentBook 设备基础台账
     * @return 结果
     */
    @Override
    public int insertEquipmentBook(EquipmentBook equipmentBook)
    {
        return equipmentBookMapper.insertEquipmentBook(equipmentBook);
    }

    /**
     * 修改设备基础台账
     *
     * @param equipmentBook 设备基础台账
     * @return 结果
     */
    @Override
    public int updateEquipmentBook(EquipmentBook equipmentBook)
    {
        return equipmentBookMapper.updateEquipmentBook(equipmentBook);
    }

    /**
     * 批量删除设备基础台账
     *
     * @param equipmentIds 需要删除的设备基础台账主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentBookByEquipmentIds(String[] equipmentIds)
    {
        return equipmentBookMapper.deleteEquipmentBookByEquipmentIds(equipmentIds);
    }

    /**
     * 删除设备基础台账信息
     *
     * @param equipmentId 设备基础台账主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentBookByEquipmentId(String equipmentId)
    {
        return equipmentBookMapper.deleteEquipmentBookByEquipmentId(equipmentId);
    }

    /**
     * 查询设备基础台账,并进行排序分页
     *
     * @param equipmentBookListVo
     * @return 设备基础台账
     */
    @Override
    public List<EquipmentBook> selectEquipmentBookListByOrder(EquipmentBookListVo equipmentBookListVo) {
        String str=equipmentBookListVo.getColumn();
        StringBuffer buf=new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isUpperCase(c)) {
                buf.append('_');
                buf.append(Character.toLowerCase(c));
            }else {
                buf.append(c);
            }
        }
        equipmentBookListVo.setColumn(buf.toString());
        if ("".equals(equipmentBookListVo.getKeyWord())){
            return equipmentBookMapper.selectEquipmentBookListByOrder(equipmentBookListVo);
        }else {
            return equipmentBookMapper.selectEquipmentBookLike(equipmentBookListVo.getKeyWord());
        }

    }
}
